package cn.wolfcode.wolf2w.business.listener;

import cn.wolfcode.wolf2w.business.api.domain.Strategy;
import cn.wolfcode.wolf2w.business.api.domain.StrategyEs;
import cn.wolfcode.wolf2w.business.repository.StrategyEsRepository;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author : 邓风来
 * @date : 2025/9/28 14:21
 */
@Component
public class StrategyRabbitListener {
    @Autowired
    private StrategyEsRepository strategyEsRepository;
    @RabbitListener(queues = "strategyQueue")
    public void onMessage(String msg){
        Strategy strategy = JSON.parseObject(msg, Strategy.class);
        StrategyEs es = new StrategyEs();
        BeanUtils.copyProperties(strategy,es);
        strategyEsRepository.save(es);
    }
}
